from api_key.model import ApiKey
from google.appengine.ext import db

def get_api_key_by_key(key):
    if not key:
        return None
    api_query = ApiKey.all().filter('__key__ =', db.Key(key))
    api = None
    apis = api_query.fetch(1)
    if len(apis) == 1:
        api = apis[0]
    return api
def get_api_key(api_key):
    if not api_key:
        return None
    api_query = ApiKey.all().filter('api_key =', api_key)
    api = None
    apis = api_query.fetch(1)
    if len(apis) == 1:
        api = apis[0]
    return api 
    